Skip to content

fix(git): preserve ssh scheme URLs with custom ports#9425

Open
Iisyourdad wants to merge 2 commits intocoollabsio:nextfrom
Iisyourdad:fix/ssh_url_stripped
Open

fix(git): preserve ssh scheme URLs with custom ports#9425
Iisyourdad wants to merge 2 commits intocoollabsio:nextfrom
Iisyourdad:fix/ssh_url_stripped

Conversation

@Iisyourdad
Copy link
Copy Markdown
Contributor

@Iisyourdad Iisyourdad commented Apr 4, 2026

Changes

  • Preserve full ssh:// repository URLs with non-standard ports for custom Git sources instead of rewriting them into invalid ssh:/... URLs.

Issues

Category

  • Bug fix

AI Assistance

  • AI was NOT used to create this PR

Testing

php artisan test tests/Feature/ConvertingGitUrlsTest.php tests/Unit/ApplicationGitSecurityTest.php and by launching up an instance.

Contributor Agreement

Important

  • I have read and understood the contributor guidelines. If I have failed to follow any guideline, I understand that this PR may be closed without review.
  • I have searched existing issues and pull requests (including closed ones) to ensure this isn't a duplicate.
  • I have tested all the changes thoroughly with a local development instance of Coolify and I am confident that they will work as expected when a maintainer tests them.

@ShadowArcanist
Copy link
Copy Markdown
Member

Can you share the steps to test this? (without using those test files)

@ShadowArcanist ShadowArcanist added the 💤 Waiting for feedback Issues awaiting a response from the author. label Apr 5, 2026
@Iisyourdad
Copy link
Copy Markdown
Contributor Author

Howdy @ShadowArcanist I completely understand why you want the exact step by step process on how to test it yourself instead of just relying on the test files.

I tested this on my own personal VPS running coolify just by plugging the file and testing.

Create your own git instance and test the bug.

If you know how to set up your own git instance ect and have been able to see the bug and the temporary fix then skip below.

  • Use the one click deploy for Gitea to setup your own custom git. Follow the basic setup and create an account ect. launch it to git.example.com
  • On Coolify, create a new ssh key and put it in your account ssh settings, not just an individual repo.

Run this command to fix ssh on gitea so that it listens on the correct port after running

docker exec -it <your_gitea_name> sh

sed -i 's/^SSH_PORT *= *.*/SSH_PORT = 22222/' /data/gitea/conf/app.ini

grep -E '^(SSH_PORT|SSH_LISTEN_PORT)' /data/gitea/conf/app.ini
exit

Make sure that your firewall allows ssh connection to gitea.

via ufw status

22222/tcp (v6) | ALLOW | Anywhere (v6)

Test out a custom git source via ssh://git@129.xxx.xxx.xx:22222/User/repo_name.git and make sure that it fails.

Test out a custom git source with the temporary fix viassh:///git@129.xxx.xxx.xx:22222/User/repo_name.git and make sure that it works.

If you are using cloudflare make sure that your DNS records are set to DNS only and not proxy.

Apply the patch.

Go into your coolify container

docker exec -u 0 -it coolify sh

rm bootstrap/helpers/shared.php
nano bootstrap/helpers/shared.php

and copy and paste the whole file in with my edits. Then,

exit

docker restart coolify

Test out custom git source again via ssh://git@129.xxx.xxx.xx:22222/User/repo_name.git and it should work!

Note

I personally had quite a few issues with recreating OP's original problem so I am 100% willing to answer any questions that you have about testing.

I have this patch running on my own VPS running coolify and its working on my machine (dangerous words ik.)

@Iisyourdad
Copy link
Copy Markdown
Contributor Author

Iisyourdad commented Apr 8, 2026

@coderabbitai do your thing!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

@Iisyourdad I'll be back... with a full review! 🤖

Those are some excellent manual testing steps you laid out — self-hosted Gitea on your own VPS, custom SSH ports, and patching directly into the Coolify container. That's the way — real servers, real iron. None of that serverless nonsense where your SSH connection gets billed per millisecond. 🌮 (Sadly I can't enjoy your celebratory tacos, gluten intolerance and all.)

Let me do a thorough review of this PR right now!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8a1fc34e-5e84-4849-b317-7e441f0f525e

📥 Commits

Reviewing files that changed from the base of the PR and between ffb5045 and d2ada90.

📒 Files selected for processing (3)
  • bootstrap/helpers/shared.php
  • tests/Feature/ConvertingGitUrlsTest.php
  • tests/Unit/ApplicationGitSecurityTest.php

Walkthrough

The pull request refactors the convertGitUrl() function to handle two distinct URL formats differently. For URLs containing ://, it now uses parse_url() to extract the port value directly without rewriting the repository URL. For SSH-style host:port/path format, it applies a named-group regex to extract port information and rewrites the repository accordingly. The changes include new feature and unit tests validating port extraction and preservation across SSH URLs with custom ports, including IPv6 hostname handling.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💤 Waiting for feedback Issues awaiting a response from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants